<template>
  <div class="suggest-config-content win-flex-row">
    <el-form ref="suggestForm" class="padding10 w100Rate" :model="suggestForm" :rules="rules" label-width="80px">
      <el-form-item label="意见反馈" prop="adviceText">
        <el-input v-model="suggestForm.adviceText" type="textarea" :rows="8"
          placeholder="请输入要反馈的意见"></el-input></el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submit">提 交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { submitAdvice } from '@/api/bvadvice/bvadvice';
export default {
  name: 'Suggest',
  components: {
  },
  data() {
    return {
      // 表单参数
      suggestForm: {
        adviceText: '',
      },
      // 表单校验
      rules: {
        adviceText: [{ required: true, message: '意见不能为空', trigger: 'blur' }],
      },
    };
  },
  created() {
  },
  computed: {
  },
  methods: {
    submit: _.debounce(function () {
      this.$refs['suggestForm'].validate(valid => {
        if (valid) {
          try {
            this.$modal.loading('提交中...');
            submitAdvice(this.suggestForm).then(res => {
              this.$modal.closeLoading();
              if (res.code == 200) {
                this.$modal.msgSuccess('提交成功');
              } else {
                this.$modal.msgError(res.msg);
              }
            });
          } catch (error) {
            console.error(error);
            this.$modal.closeLoading();
            this.$modal.msgSuccess('提交失败');
          }
        }
      });
    }, 80),
  }
};
</script>

<style lang="scss" scoped>
.suggest-config-content {}
</style>
